<template>
  <top-nav
    v-if="!isHideTop"
    :centerIndex="centerIndex"
    @topTabsClick="topTabsClick"
  ></top-nav>
  <router-view />
</template>

<script lang="ts">
import { useRouter, useRoute } from "vue-router";
import { ref, defineComponent } from "vue";
import TopNav from "@/components/TopNav.vue";
export default defineComponent({
  components: {
    TopNav,
  },
  setup() {
    const router = useRouter();
    const route = useRoute();
    const { isHideTop } = route.meta;
    console.log(route.meta);
    const centerIndex = ref<number>(1);
    const topTabsClick = (index: number, e: any) => {
      console.log(e.target.innerText);
      centerIndex.value = index;
      switch (e.target.innerText) {
        case "我的":
          router.push("/index/home");
          break;
        case "推荐":
          router.push("/index/recommend/gexingtuijian");
          break;
        case "发现":
          router.push("/index/found");
          break;
        default:
          break;
      }
    };
    return {
      topTabsClick,
      centerIndex,
      isHideTop,
    };
  },
});
</script>

<style></style>
